import { HandlerEnum } from './enum'

import { useAppStore } from '@/store/modules/app'
import type { ProjectConfig } from '@/types/config'

export function baseHandler(event: HandlerEnum, value: any) {
  const appStore = useAppStore()
  const config = handler(event, value)
  appStore.setProjectConfig(config)
}

export function handler(event: HandlerEnum, value: any): DeepPartial<ProjectConfig> {
  switch (event) {
    case HandlerEnum.MENU_WIDTH:
      return { menuSetting: { menuWidth: value } }
      // ============root==================

    case HandlerEnum.FULL_CONTENT:
      return { fullContent: value }

    // ============header==================
    case HandlerEnum.HEADER_FIXED:
      return { headerSetting: { fixed: value } }
    default:
      return {}
  }
}
